import { BasicColumn, FormSchema } from "/@/components/Table"
import { render } from "/@/utils/common/renderUtils"
import { DescItem } from "/@/components/Description/index"
import { useI18n } from "/@/hooks/web/useI18n"
const { t } = useI18n("")
export const isEventObject = (key) => key === "0"
export const columns: BasicColumn[] = [
  {
    title: t("名称"),
    dataIndex: "name",
    align: "left",
    width: 160,
  },
  {
    title: t("标识"),
    dataIndex: "id",
    align: "left",
    width: 160,
  },
  {
    title: t("排序"),
    dataIndex: "sortNo",
    width: 80,
    align: "center",
  },
  {
    title: t("创建时间"),
    dataIndex: "createdAt",
    width: 150,
    align: "center",
  },
  {
    title: t("创建者"),
    dataIndex: "createdBy",
    width: 150,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "名称",
    component: "Input",
    componentProps: {
      placeholder: "请输入名称",
    },
    // colProps: { span: 12 },
  },
]

export const inputFormSchemas: FormSchema[] = [
  {
    label: "标识",
    field: "id",
    component: "Input",
    show: ({ values }) => values.id,
    dynamicDisabled: ({ values }) => !!values.id,
  },
  {
    label: t("名称"),
    required: true,
    field: "name",
    component: "Input",
  },

  {
    label: t("父级"),
    required: false,
    field: "parentId",
    component: "MyTreeSelect",
    componentProps: {
      fieldNames: {
        title: "name",
        key: "id",
        value: "id",
      },
    },
    ifShow: ({ values }) => values.parentId != '0',
    dynamicDisabled: ({ values }) => !!values.parentId,
  },

  {
    field: "sortNo",
    label: "排序",
    component: "InputNumber",
    defaultValue: 1,
  },
  {
    label: t("备注"),
    field: "remark",
    required: false,
    component: "InputTextArea",
    componentProps: {
      maxlength: 500,
      autoSize: {
        minRows: 3,
        maxRows: 8,
      },
    },
  },
]

// export const formDetailSchema: DescItem[] = [
//   {
//     label: t("事件名"),
//     field: "eventValue",
//   },
//   {
//     label: t("事件键值"),
//     field: "eventKey",
//   },
//   {
//     label: t("创建时间"),
//     field: "createdAt",
//   },
//   {
//     label: t("更新时间"),
//     field: "updatedAt",
//   },
//   {
//     label: t("创建者"),
//     field: "createdBy",
//   },
//   {
//     label: t("更新者"),
//     field: "updatedBy",
//   },
//   {
//     label: t("备注"),
//     labelMinWidth: 40,
//     field: "remark",
//   },
// ]
